|
|
|
|
|
|
|
' Restores services to their original state
Private Sub cmdRestore_Click()
Dim so As ServiceObject
Dim stat As ServiceStatus
Dim starttimer As Boolean
Dim orig As ServiceStateConstants
Dim res&
Call LoadList(False)
Set ChangesInProgress = New Collection
For Each stat In ServiceCollection
If stat.CurrentState <> OriginalState(stat.Name) Then
ChangesInProgress.Add sc.OpenService(stat, SERVICE_START _
Or SERVICE_STOP), stat.Name
End If
Next
For Each so In ChangesInProgress
orig = OriginalState(so.ServiceName)
If orig = SERVICE_RUNNING Then
res = so.StartService
Else
res = so.ServiceControl(SERVICE_CONTROL_STOP)
End If
If res <> 0 Then
starttimer = True
Else
ChangesInProgress.Remove so.ServiceName
End If
Next so
If starttimer Then
EnablePanel False
TargetState = 0
Changed = True
Else
Set ChangesInProgress = Nothing
End If
End Sub |
|
|
|
|
|
|
|
|
When you close the application, you are given the opportunity to restore the services to their original state if any of the services have been changed by this application. If you decide to restore the services, the unload is suspended until after the restore operation is complete, and the unloadpending flag is set to True so the application will know to terminate when the services are restored to their original state. |
|
|
|
|
|